home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 February (DVD) / PCWorld_2008-02_DVD.iso / v cisle / PHP / PHP.exe / EasyPHP-2.0b1-setup.exe / {app} / phpmyadmin / libraries / header.inc.php < prev    next >
Encoding:
PHP Script  |  2006-11-18  |  11.4 KB  |  270 lines

  1. <?php
  2. /* $Id: header.inc.php 9215 2006-08-01 07:15:30Z cybot_tm $ */
  3. // vim: expandtab sw=4 ts=4 sts=4:
  4.  
  5. require_once './libraries/common.lib.php';
  6.  
  7. if (empty($GLOBALS['is_header_sent'])) {
  8.  
  9.     /**
  10.      * Gets a core script and starts output buffering work
  11.      */
  12.     require_once './libraries/common.lib.php';
  13.     require_once './libraries/ob.lib.php';
  14.     if ($GLOBALS['cfg']['OBGzip']) {
  15.         $GLOBALS['ob_mode'] = PMA_outBufferModeGet();
  16.         if ($GLOBALS['ob_mode']) {
  17.             PMA_outBufferPre($GLOBALS['ob_mode']);
  18.         }
  19.     }
  20.  
  21.     // garvin: For re-usability, moved http-headers and stylesheets
  22.     // to a seperate file. It can now be included by header.inc.php,
  23.     // querywindow.php.
  24.  
  25.     require_once './libraries/header_http.inc.php';
  26.     require_once './libraries/header_meta_style.inc.php';
  27.  
  28.     // generate title
  29.     $title     = str_replace(
  30.                     array(
  31.                         '@HTTP_HOST@',
  32.                         '@SERVER@',
  33.                         '@VERBOSE@',
  34.                         '@VSERVER@',
  35.                         '@DATABASE@',
  36.                         '@TABLE@',
  37.                         '@PHPMYADMIN@',
  38.                         ),
  39.                     array(
  40.                         PMA_getenv('HTTP_HOST') ? PMA_getenv('HTTP_HOST') : '',
  41.                         isset($GLOBALS['cfg']['Server']['host']) ? $GLOBALS['cfg']['Server']['host'] : '',
  42.                         isset($GLOBALS['cfg']['Server']['verbose']) ? $GLOBALS['cfg']['Server']['verbose'] : '',
  43.                         !empty($GLOBALS['cfg']['Server']['verbose']) ? $GLOBALS['cfg']['Server']['verbose'] : (isset($GLOBALS['cfg']['Server']['host']) ? $GLOBALS['cfg']['Server']['host'] : ''),
  44.                         isset($GLOBALS['db']) ? $GLOBALS['db'] : '',
  45.                         isset($GLOBALS['table']) ? $GLOBALS['table'] : '',
  46.                         'phpMyAdmin ' . PMA_VERSION,
  47.                         ),
  48.                     !empty($GLOBALS['table']) ? $GLOBALS['cfg']['TitleTable'] :
  49.                     (!empty($GLOBALS['db']) ? $GLOBALS['cfg']['TitleDatabase'] :
  50.                     (!empty($GLOBALS['cfg']['Server']['host']) ? $GLOBALS['cfg']['TitleServer'] :
  51.                     $GLOBALS['cfg']['TitleDefault']))
  52.                     );
  53.     // here, the function does not exist with this configuration: $cfg['ServerDefault'] = 0;
  54.     $is_superuser    = function_exists('PMA_isSuperuser') && PMA_isSuperuser();
  55.     ?>
  56.     <script type="text/javascript" language="javascript">
  57.     // <![CDATA[
  58.     // Updates the title of the frameset if possible (ns4 does not allow this)
  59.     if (typeof(parent.document) != 'undefined' && typeof(parent.document) != 'unknown'
  60.         && typeof(parent.document.title) == 'string') {
  61.         parent.document.title = '<?php echo PMA_sanitize(str_replace('\'', '\\\'', $title)); ?>';
  62.     }
  63.     <?php
  64.     // Add some javascript instructions if required
  65.     if (isset($js_to_run) && $js_to_run == 'functions.js') {
  66.         echo "\n";
  67.         ?>
  68.     // js form validation stuff
  69.     var errorMsg0   = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strFormEmpty']); ?>';
  70.     var errorMsg1   = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strNotNumber']); ?>';
  71.     var noDropDbMsg = '<?php echo (!$is_superuser && !$GLOBALS['cfg']['AllowUserDropDatabase'])
  72.         ? str_replace('\'', '\\\'', $GLOBALS['strNoDropDatabases']) : ''; ?>';
  73.     var confirmMsg  = '<?php echo(($GLOBALS['cfg']['Confirm']) ? str_replace('\'', '\\\'', $GLOBALS['strDoYouReally']) : ''); ?>';
  74.     var confirmMsgDropDB  = '<?php echo(($GLOBALS['cfg']['Confirm']) ? str_replace('\'', '\\\'', $GLOBALS['strDropDatabaseStrongWarning']) : ''); ?>';
  75.     // ]]>
  76.     </script>
  77.     <script src="./js/functions.js" type="text/javascript" language="javascript"></script>
  78.         <?php
  79.     } elseif (isset($js_to_run) && $js_to_run == 'user_password.js') {
  80.         echo "\n";
  81.         ?>
  82.     // js form validation stuff
  83.     var jsHostEmpty       = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strHostEmpty']); ?>';
  84.     var jsUserEmpty       = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strUserEmpty']); ?>';
  85.     var jsPasswordEmpty   = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strPasswordEmpty']); ?>';
  86.     var jsPasswordNotSame = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strPasswordNotSame']); ?>';
  87.     // ]]>
  88.     </script>
  89.     <script src="./js/user_password.js" type="text/javascript" language="javascript"></script>
  90.         <?php
  91.     } elseif (isset($js_to_run) && $js_to_run == 'server_privileges.js') {
  92.         echo "\n";
  93.         ?>
  94.     // js form validation stuff
  95.     var jsHostEmpty       = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strHostEmpty']); ?>';
  96.     var jsUserEmpty       = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strUserEmpty']); ?>';
  97.     var jsPasswordEmpty   = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strPasswordEmpty']); ?>';
  98.     var jsPasswordNotSame = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strPasswordNotSame']); ?>';
  99.     // ]]>
  100.     </script>
  101.     <script src="./js/server_privileges.js" type="text/javascript" language="javascript"></script>
  102.     <script src="./js/functions.js" type="text/javascript" language="javascript"></script>
  103.         <?php
  104.     } elseif (isset($js_to_run) && $js_to_run == 'indexes.js') {
  105.         echo "\n";
  106.         ?>
  107.     // js index validation stuff
  108.     var errorMsg0   = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strFormEmpty']); ?>';
  109.     var errorMsg1   = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strNotNumber']); ?>';
  110.     // ]]>
  111.     </script>
  112.     <script src="./js/indexes.js" type="text/javascript" language="javascript"></script>
  113.         <?php
  114.     } elseif (isset($js_to_run) && $js_to_run == 'tbl_change.js') {
  115.         echo "\n";
  116.         ?>
  117.     // ]]>
  118.     </script>
  119.     <script src="./js/tbl_change.js" type="text/javascript" language="javascript"></script>
  120.         <?php
  121.     } else {
  122.         echo "\n";
  123.         ?>
  124.     // ]]>
  125.     </script>
  126.         <?php
  127.     }
  128.     echo "\n";
  129.  
  130.     // Reloads the navigation frame via JavaScript if required
  131.     PMA_reloadNavigation();
  132.     ?>
  133.     <script src="./js/tooltip.js" type="text/javascript"
  134.         language="javascript"></script>
  135.     <meta name="OBGZip" content="<?php echo ($cfg['OBGzip'] ? 'true' : 'false'); ?>" />
  136.     <?php /* remove vertical scroll bar bug in ie */ ?>
  137.     <!--[if IE 6]>
  138.     <style type="text/css">
  139.     /* <![CDATA[ */
  140.     html {
  141.         overflow-y: scroll;
  142.     }
  143.     /* ]]> */
  144.     </style>
  145.     <![endif]-->
  146. </head>
  147.  
  148. <body>
  149. <div id="TooltipContainer" onmouseover="holdTooltip();" onmouseout="swapTooltip('default');"></div>
  150.     <?php
  151.  
  152.     // Include possible custom headers
  153.     if (file_exists('./config.header.inc.php')) {
  154.         require './config.header.inc.php';
  155.     }
  156.  
  157.  
  158.     // message of "Cookies required" displayed for auth_type http or config
  159.     // note: here, the decoration won't work because without cookies,
  160.     // our standard CSS is not operational
  161.     if (empty($_COOKIE)) {
  162.          echo '<div class="notice">' . $GLOBALS['strCookiesRequired'] . '</div>' . "\n";
  163.     }
  164.  
  165.     if (!defined('PMA_DISPLAY_HEADING')) {
  166.         define('PMA_DISPLAY_HEADING', 1);
  167.     }
  168.  
  169.     /**
  170.      * Display heading if needed. Design can be set in css file.
  171.      */
  172.  
  173.     if (PMA_DISPLAY_HEADING) {
  174.         $server_info = (!empty($GLOBALS['cfg']['Server']['verbose'])
  175.                         ? $GLOBALS['cfg']['Server']['verbose']
  176.                         : $GLOBALS['cfg']['Server']['host'] . (empty($GLOBALS['cfg']['Server']['port'])
  177.                                                                ? ''
  178.                                                                : ':' . $GLOBALS['cfg']['Server']['port']
  179.                                                               )
  180.                        );
  181.         $item = '<a href="%1$s?%2$s" class="item">';
  182.         if ( $GLOBALS['cfg']['NavigationBarIconic'] ) {
  183.             $separator = '        <span class="separator"><img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 'item_ltr.png" width="5" height="9" alt="-" /></span>' . "\n";
  184.             $item .= '        <img class="icon" src="' . $GLOBALS['pmaThemeImage'] . '%5$s" width="16" height="16" alt="" /> ' . "\n";
  185.         } else {
  186.             $separator = '        <span class="separator"> - </span>' . "\n";
  187.         }
  188.  
  189.         if ( $GLOBALS['cfg']['NavigationBarIconic'] !== true ) {
  190.             $item .= '%4$s: ';
  191.         }
  192.         $item .= '%3$s</a>' . "\n";
  193.  
  194.         echo '<div id="serverinfo">' . "\n";
  195.         printf( $item,
  196.                 $GLOBALS['cfg']['DefaultTabServer'],
  197.                 PMA_generate_common_url(),
  198.                 htmlspecialchars($server_info),
  199.                 $GLOBALS['strServer'],
  200.                 's_host.png' );
  201.  
  202.         if (isset($GLOBALS['db']) && strlen($GLOBALS['db'])) {
  203.  
  204.             echo $separator;
  205.             printf( $item,
  206.                     $GLOBALS['cfg']['DefaultTabDatabase'],
  207.                     PMA_generate_common_url($GLOBALS['db']),
  208.                     htmlspecialchars($GLOBALS['db']),
  209.                     $GLOBALS['strDatabase'],
  210.                     's_db.png' );
  211.  
  212.             if (isset($GLOBALS['table']) && strlen($GLOBALS['table'])) {
  213.                 require_once './libraries/tbl_properties_table_info.inc.php';
  214.  
  215.                 echo $separator;
  216.                 printf( $item,
  217.                         $GLOBALS['cfg']['DefaultTabTable'],
  218.                         PMA_generate_common_url($GLOBALS['db'], $GLOBALS['table']),
  219.                         htmlspecialchars($GLOBALS['table']),
  220.                         (isset($GLOBALS['tbl_is_view']) && $GLOBALS['tbl_is_view'] ? $GLOBALS['strView'] : $GLOBALS['strTable']),
  221.                         (isset($GLOBALS['tbl_is_view']) && $GLOBALS['tbl_is_view'] ? 'b_views' : 's_tbl') . '.png' );
  222.  
  223.                 /**
  224.                  * Displays table comment
  225.                  * @uses $show_comment from libraries/tbl_properties_table_info.inc.php
  226.                  * @uses $GLOBALS['avoid_show_comment'] from tbl_relation.php
  227.                  */
  228.                 if (!empty($show_comment) && !isset($GLOBALS['avoid_show_comment'])) {
  229.                     if (strstr($show_comment, '; InnoDB free')) {
  230.                         $show_comment = preg_replace('@; InnoDB free:.*?$@', '', $show_comment);
  231.                     }
  232.                     echo '<span class="table_comment" id="span_table_comment">'
  233.                         .'"' . htmlspecialchars($show_comment)
  234.                         .'"</span>' . "\n";
  235.                 } // end if
  236.             } else {
  237.                 // no table selected, display database comment if present
  238.                 /**
  239.                  * Settings for relations stuff
  240.                  */
  241.                 require_once './libraries/relation.lib.php';
  242.                 $cfgRelation = PMA_getRelationsParam();
  243.  
  244.                 // Get additional information about tables for tooltip is done
  245.                 // in libraries/db_details_db_info.inc.php only once
  246.                 if ($cfgRelation['commwork']) {
  247.                     $comment = PMA_getComments( $GLOBALS['db'] );
  248.  
  249.                     /**
  250.                      * Displays table comment
  251.                      */
  252.                     if ( is_array( $comment ) ) {
  253.                         echo '<span class="table_comment"'
  254.                             .' id="span_table_comment">"'
  255.                             .htmlspecialchars(implode(' ', $comment))
  256.                             .'"</span>' . "\n";
  257.                     } // end if
  258.                 }
  259.             }
  260.         }
  261.         echo '</div>';
  262.  
  263.     }
  264.     /**
  265.      * Sets a variable to remember headers have been sent
  266.      */
  267.     $GLOBALS['is_header_sent'] = true;
  268. }
  269. ?>
  270.